#include "EnemyDie.h"
#include "Sprite.h"
#include "RSManager.h"
#include "Box.h"
#include "ShareComponents.h"


EnemyDie::~EnemyDie(void)
{
}

void EnemyDie::update()
{
	delay += GAME_TIME;
	if(delay > 150 && _isAlive)
	{
		delay = 0;
		steps++;
		_sprite->Next();
	}
	if(steps >= 2)
	{
		_isAlive = false;
	}
}

void EnemyDie::render()
{
	_sprite->Render(_box->_position);
}

EnemyDie::EnemyDie(Box* box, ObjectType objT, SPRITE_ID id) : Object(box, objT)
{
	_objType = objT;	
	_sprite = RSManager::getInstance()->getSprite(id);
	delay = 0;
	steps = 0;
	_isAlive = true;
}

Box* EnemyDie::getCollisionBox()
{
	if (_objType == Obj_Anti)
	{
		_colBox->_position = _box->_position;
		_colBox->_size = _sprite->getRenderSize();
		_colBox->_v = _box->_v;
		_colBox->_position.x -= _colBox->_size.x/2;
		return _colBox;
	}
	return gl_BOX_0_0_0;
}
